package com.chenbei.schedule.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.chenbei.schedule.domain.ScheduleJobLog;
import com.chenbei.schedule.mapper.ScheduleJobLogMapper;
import com.chenbei.schedule.service.ScheduleJobLogService;
import com.chenbei.schedule.vo.req.ScheduleJobLogReq;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.concurrent.locks.ReentrantLock;

@Slf4j
@Service
public class ScheduleJobLogServiceImpl extends ServiceImpl<ScheduleJobLogMapper, ScheduleJobLog> implements ScheduleJobLogService {

    @Override
    public Page<ScheduleJobLog> pageList(ScheduleJobLogReq req) {
        LambdaQueryWrapper<ScheduleJobLog> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(ScheduleJobLog::getJobId, req.getJobId())
                .orderByDesc(ScheduleJobLog::getId);

        Page<ScheduleJobLog> pageConfig = new Page<>(req.getPageNum(), req.getPageSize());
        return page(pageConfig, lambdaQueryWrapper);
    }
}
